/**
 * 
 */
package ac.svn.accesscontrol.ui.window;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.MouseInfo;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EtchedBorder;

import ac.framework.ui.shadowed.white.WhiteGradientLabel;
import ac.svn.accesscontrol.ui.IUIConstants;
import ac.svn.accesscontrol.ui.UIComponentLibrary;

/**
 * @author Enigmanic
 *
 */
public class IntellisensePanel extends JPanel implements IUIConstants {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JList lstItems;
	private JTextField txtSearch;
	private JLabel titleLabel;
	private JLabel statusLabel;
	private JButton helpButton;

	public IntellisensePanel()
	{
		super(new BorderLayout());
		initComponents();
	}

	private void initComponents() {
		JPanel basePanel = new JPanel();

		basePanel.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, new Color(255, 255, 255)));
		basePanel.setBackground(Color.GRAY);
		add(basePanel, BorderLayout.CENTER);
		basePanel.setLayout(new BorderLayout(0, 0));

		JScrollPane scrpList = new JScrollPane();
		basePanel.add(scrpList, BorderLayout.CENTER);

		lstItems = new JList();
		scrpList.setViewportView(lstItems);

		JPanel pnlSearchBase = new JPanel();
		basePanel.add(pnlSearchBase, BorderLayout.NORTH);
		pnlSearchBase.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
		pnlSearchBase.setLayout(new BorderLayout(0, 0));

		txtSearch = new JTextField();
		pnlSearchBase.add(txtSearch);
		txtSearch.setColumns(10);

		titleLabel = new WhiteGradientLabel("Choose");
		titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
		pnlSearchBase.add(titleLabel, BorderLayout.NORTH);
		
		helpButton = new JButton("?");
		pnlSearchBase.add(helpButton, BorderLayout.EAST);

		statusLabel = new WhiteGradientLabel(" Filter Result ");
		statusLabel.setHorizontalAlignment(SwingConstants.RIGHT);
		basePanel.add(statusLabel, BorderLayout.SOUTH);

		registerComponents();
	}

	private void registerComponents() {
		UIComponentLibrary.addComponent(C_INTEL_ITEM_LIST,lstItems);
		UIComponentLibrary.addComponent(C_INTEL_WINDOW,this);
		UIComponentLibrary.addComponent(C_INTEL_SEARCH_TEXT,txtSearch);
		UIComponentLibrary.addComponent(C_INTEL_ITEM_MODEL_GROUP,(new DefaultListModel()));
		UIComponentLibrary.addComponent(C_INTEL_ITEM_MODEL_USER,(new DefaultListModel()));
		UIComponentLibrary.addComponent(C_INTEL_ITEM_MODEL_LOCATION,(new DefaultListModel()));
	}
	public JList getLstItems() {
		return lstItems;
	}

	public JTextField getTxtSearch() {
		return txtSearch;
	}

	public static void main(String args[])
	{
		IntellisensePanel intellisenseWindow = new IntellisensePanel();
		intellisenseWindow.setVisible(true);
	}

	public void setVisible(boolean b)
	{
		setLocation(MouseInfo.getPointerInfo().getLocation());
		super.setVisible(b);
	}

	/**
	 * @return the titleLabel
	 */
	public JLabel getTitleLabel() {
		return titleLabel;
	}

	/**
	 * @param titleLabel the titleLabel to set
	 */
	public void setTitleLabel(JLabel titleLabel) {
		this.titleLabel = titleLabel;
	}

	/**
	 * @return the statusLabel
	 */
	public JLabel getStatusLabel() {
		return statusLabel;
	}

	/**
	 * @return the helpButton
	 */
	public JButton getHelpButton() {
		return helpButton;
	}
}
